# -*- coding: utf-8 -*-
# @Time : 2021/7/3 9:45
# @Author : 摘星星的小女孩
# @Email : wayne_lau@aliyun.com
# @File : page_ecshop_front_modify_user_information.py
# @Project : ecshop


from selenium.webdriver.common.by import By


class PageEcshopFrontModifyUserInformation():
    def __init__(self,driver):
        self.driver=driver
        #元素定位符loc

        self.loc_ele_old_password=(By.NAME, "old_password") #旧密码
        self.loc_ele_new_password=(By.NAME, "new_password") #新密码
        self.loc_ele_comfirm_password=(By.NAME,"comfirm_password") #确认密码
        self.loc_ele_submit=(By.XPATH,"/html/body/div[8]/div[2]/div/div/div/form[2]/table/tbody/tr[4]/td/input[2]")  #确认按钮
        self.loc_ele_user_center_assert=(By.XPATH,'//font[@id="ECS_MEMBERZONE"]/a[2]')  #断言


    #登录
    def ele_old_password(self,old_password):
        '''旧密码输入框'''
        self.driver.find_element(*self.loc_ele_old_password).send_keys(old_password)

    def ele_new_password(self,new_password):
        '''新密码输入框'''
        self.driver.find_element(*self.loc_ele_new_password).send_keys(new_password)



    def ele_comfirm_password(self,comfirm_password):

        '''确认密码输入框'''
        self.driver.find_element(*self.loc_ele_comfirm_password).send_keys(comfirm_password)


    def ele_submit(self):
        self.driver.find_element(*self.loc_ele_submit).click()

    def ele_user_center_assert(self):
        '''断言-修改信息后会注销当前登录，所以断言“登录”'''
        actual=self.driver.find_element(*self.loc_ele_user_center_assert).text
        return  actual  #实际结果



    def modify_user_information(self,old_password,new_password,comfirm_password):
        '''封装为修改用户信息包'''

        self.ele_old_password(old_password)
        self.ele_new_password(new_password)
        self.ele_comfirm_password(comfirm_password)
        actual= self.ele_user_center_assert()
        return actual  #返回断言
